package com.xw.db137.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.xw.db137.common.R;
import com.xw.db137.entity.Menu;
import org.apache.ibatis.annotations.*;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

/**
 * @Author: xw
 * @CreateTime: 2024/12/24
 * @Description: 用户
 * @Version: 1.0
 */
public interface MenuMapper extends BaseMapper<Menu> {
    @Select("SELECT DISTINCT(m.`id`),m.`label`,m.`href`,m.`imgicon`,m.`parentid` FROM userrole u INNER JOIN rolemenu r ON u.`roleid`=r.`roleid` INNER JOIN menu m ON r.`menuid`=m.`id` WHERE u.`userid`=#{id}")
    public List<Menu> selectMenuByUserId(@Param("id") int id);
    @Delete("DELETE FROM `menu` WHERE id=#{id} ")
    public int deleteMenu(@Param("id") String id);
    @Update("UPDATE `menu` SET label=#{label} ,href=#{href} ,imgicon=#{imgicon} ,parentid=#{parentid}  WHERE id=#{id} ")
    public int updateMenuById(Menu menu);
    @Insert("INSERT  INTO `menu` VALUES (null,#{label} ,#{href} ,#{imgicon} ,#{parentid})")
    public int insertMenu(Menu menu);
}